<html>
    <head>
        <meta charset="utf-8" />
        <title>网页版群聊</title>
    </head>
    <body>
        <script>
            ws = new WebSocket("ws://www.chat.com:2345");
            ws.onopen = function() {
                console.log("连接成功");
                ws.send('tom');
                console.log("给服务端发送一个字符串：tom");
            };
            ws.onmessage = function(e) {
                console.log("收到服务端的消息：" + e.data);
            };
        </script>
    </body>
</html>